package com.project.entity.activity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Where;

import com.project.entity.BaseEntity;
import com.project.entity.enumcommon.PublishStatusEnum;
import com.project.entity.sys.Area;

@Entity
@Table(name="B_ACTIVITY")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@DynamicInsert
@DynamicUpdate
public class Activity extends BaseEntity{
	
	public Activity() {}
	
	public Activity (Long id, String name, Date activityStartDate, Date activityEndDate, Date registrationStartTime, Date registrationEndTime,
			String province, String city, String district, String address, String content, String qrcodeUrl, String coverPicUrl, PublishStatusEnum publishStatus,
			String createUser, Date createTime, String updateUser, Date updateTime, long enrollmentNum, long adoptNum) {
		super.id=id;
		this.name=name;
		this.activityStartDate=activityStartDate;
		this.activityEndDate=activityEndDate;
		this.registrationStartTime=registrationStartTime;
		this.registrationEndTime=registrationEndTime;
		this.province=province;
		this.city=city;
		this.district=district;
		this.address=address;
		this.content=content;
		this.qrcodeUrl=qrcodeUrl;
		this.coverPicUrl=coverPicUrl;
		this.publishStatus=publishStatus;
		this.createUser=createUser;
		this.createTime=createTime;
		this.updateUser=updateUser;
		this.updateTime=updateTime;
		this.enrollmentNum=enrollmentNum;
		this.adoptNum=adoptNum;
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = -6218939386133736564L;

	@Column
	private String name;//活动名称
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="activity_start_date")
	private Date activityStartDate;//活动开始日期
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="activity_end_date")
	private Date activityEndDate; //活动结束日期
	
	@Temporal(TemporalType.DATE)
	@Column(name="registration_start_time")
	private Date registrationStartTime;//报名开始时间
	
	@Temporal(TemporalType.DATE)
	@Column(name="registration_end_time")
	private Date registrationEndTime; //报名结束时间
	
	@Column
	private String province;//省
	
	@Column
	private String city;//市
	
	@Column
	private String district;//区
	
	@Column
	private String address;//地址
	
	@Column
	private String content;//内容
	
	@Column(name="ali_content")
	private String aliContent;//走进阿里内容
	
	@Column(name="qrcode_url")
	private String qrcodeUrl;//二维码图片地址
	
	@Column(name="cover_pic_url")
	private String coverPicUrl;//封面图片url
	
	@Column(name="publish_status")
	@Enumerated(EnumType.STRING)
	private PublishStatusEnum publishStatus;//发布状态(N:未发布P:已发布)
	
	@Column(name="create_user")
	private String createUser;//创建人
	
	@Column(name="create_time")
	private Date createTime;//创建时间
	
	@Column(name="update_user")
	private String updateUser;//修改人
	
	@Column(name="update_time")
	private Date updateTime;//修改时间
	
	@Transient
	private long enrollmentNum;//报名人数
	
	@Transient
	private long adoptNum;//通过人数
	
	@OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.REFRESH,targetEntity=ActivityGuest.class)
	@JoinColumns(value={@JoinColumn(name="activity_id",referencedColumnName="id",updatable=false,insertable=false)})
	@Where(clause="dr=0")
	private List<ActivityGuest>  activityGuestList = new ArrayList<ActivityGuest>();

	@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.REFRESH)
	@JoinColumn(name="province",referencedColumnName="code",updatable=false,insertable=false)
	private Area provinceEntity;
	
	@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.REFRESH)
	@JoinColumn(name="city",referencedColumnName="code",updatable=false,insertable=false)
	private Area cityEntity;
	
	@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.REFRESH)
	@JoinColumn(name="district",referencedColumnName="code",updatable=false,insertable=false)
	private Area districtEntity;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getActivityStartDate() {
		return activityStartDate;
	}

	public void setActivityStartDate(Date activityStartDate) {
		this.activityStartDate = activityStartDate;
	}

	public Date getActivityEndDate() {
		return activityEndDate;
	}

	public void setActivityEndDate(Date activityEndDate) {
		this.activityEndDate = activityEndDate;
	}

	public Date getRegistrationStartTime() {
		return registrationStartTime;
	}

	public void setRegistrationStartTime(Date registrationStartTime) {
		this.registrationStartTime = registrationStartTime;
	}

	public Date getRegistrationEndTime() {
		return registrationEndTime;
	}

	public void setRegistrationEndTime(Date registrationEndTime) {
		this.registrationEndTime = registrationEndTime;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getQrcodeUrl() {
		return qrcodeUrl;
	}

	public void setQrcodeUrl(String qrcodeUrl) {
		this.qrcodeUrl = qrcodeUrl;
	}

	public String getCoverPicUrl() {
		return coverPicUrl;
	}

	public void setCoverPicUrl(String coverPicUrl) {
		this.coverPicUrl = coverPicUrl;
	}

	public PublishStatusEnum getPublishStatus() {
		return publishStatus;
	}

	public void setPublishStatus(PublishStatusEnum publishStatus) {
		this.publishStatus = publishStatus;
	}

	public String getCreateUser() {
		return createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public long getEnrollmentNum() {
		return enrollmentNum;
	}

	public void setEnrollmentNum(long enrollmentNum) {
		this.enrollmentNum = enrollmentNum;
	}

	public long getAdoptNum() {
		return adoptNum;
	}

	public void setAdoptNum(long adoptNum) {
		this.adoptNum = adoptNum;
	}

	public String getAliContent() {
		return aliContent;
	}

	public void setAliContent(String aliContent) {
		this.aliContent = aliContent;
	}

	public List<ActivityGuest> getActivityGuestList() {
		return activityGuestList;
	}

	public void setActivityGuestList(List<ActivityGuest> activityGuestList) {
		this.activityGuestList = activityGuestList;
	}

	public Area getProvinceEntity() {
		return provinceEntity;
	}

	public void setProvinceEntity(Area provinceEntity) {
		this.provinceEntity = provinceEntity;
	}

	public Area getCityEntity() {
		return cityEntity;
	}

	public void setCityEntity(Area cityEntity) {
		this.cityEntity = cityEntity;
	}

	public Area getDistrictEntity() {
		return districtEntity;
	}

	public void setDistrictEntity(Area districtEntity) {
		this.districtEntity = districtEntity;
	}
	
}
